<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../vue.js"></script>
</head>

<body>
  <div id="app">
    <!-- 注意这里不能使用驼峰命名法了, 要将props中的驼峰命名的转换为短线命名 -->
    <cpn :son-message="message" :son-person="person"></cpn>
  </div>

  <template id="cpn">
    <div>
      <!-- 这里使用的数据, 要与props中的数据名一致 -->
      <h2>{{sonMessage}}</h2>
      <p>{{sonPerson}}</p>
    </div>
  </template>
  <script>
    const cpn = {
      template: "#cpn",
      props: {
        sonMessage: {
          type: String,
          default: "你好你好"
        },
        sonPerson: {
          type: Object,
          default () {
            return {}
          }
        }
      }
    }
    const app = new Vue({
      el: "#app",
      data: {
        message: "我是传入的数据",
        person: {
          name: "xiaoLam",
          age: 22
        }
      },
      components: {
        cpn
      }
    })
  </script>
</body>

</html>